﻿@using Jb.Framework.Common.Forms
@using Jb.Framework.Web.Mvc
@model Jb.Framework.Common.Forms.JbCheckBox

@{    
    var titlevalue = Model.Title;
    var labelHtmlAttr = new Dictionary<string, object> { { "class", "Custom-label pull-left" }, { "data-value", titlevalue } };
    var checkBoxHtmlAttr = new Dictionary<string, object> { { "class", "icheck" }, { "title", @Model.HelpText } };    
}

<div class="pull-left form-group check-box" style="display: @(Model.VisibleMode != VisibilityMode.Both && Model.VisibleMode != (VisibilityMode)ViewBag.VisibleMode ? "none" : "block")">
    @Html.Hidden("ModelType", Model.GetType())

    @for (var i = 0; i < Model.Validations.Count; i++)
    {
        @Html.HiddenFor(x => x.Validations[i].Type)
        @Html.HiddenFor(x => x.Validations[i].Message)
    }

    @Html.GenerateHiddenFields(Model)

    @foreach (var accRole in Model.AccessRole)
    { 
        @Html.HiddenFor(modelItem => accRole)
    }
    @Html.CheckBoxFor(x => x.Value, checkBoxHtmlAttr)
    @Html.LabelFor(x => x.Value, htmlAttributes: labelHtmlAttr)
    @if (!string.IsNullOrEmpty(Model.HelpText))
    {
        <a class="name-info" data-container="body" rel="popover" data-placement="top" data-content="@Model.HelpText"></a>        
@*<a href="#" class="name-info pull-left" data-container="body" rel="popover" data-placement="top" data-content="@Model.HelpText"></a>*@
    }
    @Html.ValidationMessageFor(model => model.Value)
</div>

<script type="text/javascript">

    //get data-value and set to html to correct show value
    $(".Custom-label").each(function () {
        $(this).html($(this).data("value"));
    });

    $(document).ready(function () {
        // initial popover function in DisplayForms
        popoverInit();
    });
</script>
